﻿using System.Collections.Generic;
using System.Web.Services;
using BLL;
using BLL.RF.ATETest;
using Model;
using Model.RF.ATETest;

/// <summary>
///TestDataUploadService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
//若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。 
// [System.Web.Script.Services.ScriptService]
public class TestDataUploadService : System.Web.Services.WebService
{
    private Test t;
    private ProductType p;
    private PackageProduct pp;
    private ProductType_Flow pf;
    private ProductType_ZTE pz;
    private tb_result_DFL tb;

    public TestDataUploadService()
    {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
        t = new Test();
        p = new ProductType();
        pp = new PackageProduct();
        pf = new ProductType_Flow();
        pz = new ProductType_ZTE();
        tb = new tb_result_DFL();
    }

    [WebMethod(Description = "判断序列号是否合法")]
    public bool IsValidProductSN(string productSN)
    {
        return !string.IsNullOrEmpty(pp.IsUnionProductSN(productSN));
    }

    [WebMethod(Description = "判断产品类型是否合法")]
    public bool IsValidProductTypeID(string productTypeID)
    {
        return !string.IsNullOrEmpty(p.LoadEntity(productTypeID).ProductTypeID);
    }

    [WebMethod(Description = "判断之前工序是否有合格记录")]
    public bool ProductType_Flow_HasValidSevenStep(string productSN,string productTypeID)
    {
        return pf.ProductType_Flow_HasValidSevenStep(productSN, productTypeID, "ATEStep");
    }

    [WebMethod(Description = "上传测试数据")]
    public bool TestData_Upload(TestInfo ti, List<TestItemInfo> items)
    {
        return t.ATETestData_Upload(ti, items);
    }

    [WebMethod(Description = "是否需要上传中兴格式数据的产品类型")]
    public bool Isvalid_ProductType_ZTE(string productTypeID)
    {
        return !string.IsNullOrEmpty(pz.LoadEntity(productTypeID).ProductTypeID);
    }

    [WebMethod(Description = "上传中兴格式测试数据")]
    public bool ZTE_TestData_Upload(tb_result_DFL_Info ti, string productTypeID, List<tb_Param_DFL_Info> items)
    {
        return tb.tb_ATETestAndItem_Insert(ti, productTypeID, items);
    }
}

